/*
@author https://yunp.top
 */
@file:JsQualifier("createjs")

package createjs

import js.Array
import org.w3c.dom.HTMLCanvasElement
import org.w3c.dom.HTMLImageElement
import org.w3c.dom.HTMLVideoElement

open external class Graphics {
    companion object {
        val BASE_64: dynamic
        val beginCmd: dynamic
        val STROKE_CAPS_MAP: Array<dynamic>
        val STROKE_JOINTS_MAP: Array<dynamic>

        fun getHSL(hue: Int, saturation: Int, lightness: Int, alpha: Float = definedExternally): String
        fun getRGB(r: Int, g: Int, b: Int, alpha: Float = definedExternally): String
    }

    val instructions: Array<dynamic>
    var command: dynamic

    fun append(command: dynamic, clean: Boolean): Graphics
    fun arc(x: Int, y: Int, radius: Int, startAngle: Int, endAngle: Int, anticlockwise: Boolean): Graphics
    fun arcTo(x1: Int, y1: Int, x2: Int, y2: Int, radius: Int): Graphics

    /**
     * @param repetition "repeat", "repeat-x", "repeat-y", or "no-repeat".
     * @see https://createjs.com/docs/easeljs/classes/Graphics.html#method_beginBitmapFill
     */
    fun beginBitmapFill(
        image: HTMLImageElement,
        repetition: String = definedExternally,
        matrix: Matrix2D = definedExternally
    ): Graphics

    /**
     * @param repetition "repeat", "repeat-x", "repeat-y", or "no-repeat".
     */
    fun beginBitmapFill(
        image: HTMLCanvasElement,
        repetition: String = definedExternally,
        matrix: Matrix2D = definedExternally
    ): Graphics

    /**
     * @param repetition "repeat", "repeat-x", "repeat-y", or "no-repeat".
     */
    fun beginBitmapFill(
        image: HTMLVideoElement,
        repetition: String = definedExternally,
        matrix: Matrix2D = definedExternally
    ): Graphics

    /**
     * @param repetition One of "repeat", "repeat-x", "repeat-y", or "no-repeat". Defaults to "repeat".
     */
    fun beginBitmapStroke(image: HTMLImageElement, repetition: String = definedExternally): Graphics

    /**
     * @param repetition One of "repeat", "repeat-x", "repeat-y", or "no-repeat". Defaults to "repeat".
     */
    fun beginBitmapStroke(image: HTMLVideoElement, repetition: String = definedExternally): Graphics

    /**
     * @param repetition One of "repeat", "repeat-x", "repeat-y", or "no-repeat". Defaults to "repeat".
     */
    fun beginBitmapStroke(image: HTMLCanvasElement, repetition: String = definedExternally): Graphics

    fun beginFill(color: String): Graphics

    fun beginLinearGradientFill(
        colors: Array<String>,
        ratios: Array<Float>,
        x0: Int,
        y0: Int,
        x1: Int,
        y1: Int
    ): Graphics

    fun beginLinearGradientStroke(
        colors: Array<String>,
        ratios: Array<Float>,
        x0: Int,
        y0: Int,
        x1: Int,
        y1: Int
    ): Graphics

    fun beginRadialGradientFill(
        colors: Array<String>,
        ratios: Array<Float>,
        x0: Int,
        y0: Int,
        r0: Int,
        x1: Int,
        y1: Int,
        r1: Int
    ): Graphics

    fun beginRadialGradientStroke(
        colors: Array<String>,
        ratios: Array<Float>,
        x0: Int,
        y0: Int,
        r0: Int,
        x1: Int,
        y1: Int,
        r1: Int
    ): Graphics

    fun beginStroke(color: String): Graphics

    fun bezierCurveTo(cp1x: Int, cp1y: Int, cp2x: Int, cp2y: Int, x: Int, y: Int): Graphics

    fun clear(): Graphics

    fun clone(): Graphics

    fun closePath(): Graphics

    fun curveTo(cpx: Int, cpy: Int, x: Int, y: Int): Graphics

    fun decodePath(str: String): Graphics

    fun drawRect(x: Int, y: Int, w: Int, h: Int): Graphics

    // TODO doc ref https://createjs.com/docs/easeljs/classes/Graphics.html
}